quietly{
/* This file contains the data used in all the figures in the paper,
except as otherwise noted.
*/
	
* USE THIS ONE FOR DESKTOP after importing data:
cd "C:\Users\achen\Documents\Word\citizen assemblies\Krashinsky project\BC combined 2005 2009"

* USE THIS ONE FOR LAPTOP
*use "C:\Users\achen.POL-PF10YAEL\Documents\Word\citizen assemblies\Krashinsky project\BC combined 2005 2009\bc combined 2005 2009.dta" 
*cd "C:\Users\achen.POL-PF10YAEL\Documents\Word\citizen assemblies\krashinsky project\BC combined 2005 2009

*IS THIS THE LOG FILE YOU WANT?  ALSO CHECK LOG CLOSE AT END.
log using bc20052009combinedrun.txt, replace text
datetime
version 18
svyset [pweight  = weight]
*Figure 1:  calculations for figure 1 (numbered as of Feb 2024):
gen year = 2005
replace year = 2009 if INTYEAR == 2009
}
svy: tab refinfo1 year, pearson col miss
svy: tab refinfo2 year, pearson col miss
svy: tab refinfo3 year, pearson col miss
svy: tab refinfo4 year, pearson col miss
svy: tab refinfo5 year, pearson col miss
svy: tab refinfo6 year, pearson col miss
gen year2009 =0
replace year2009 = 1 if year==2009
gen year2005 = 1 - year2009
*sureg doesn't work with svy, hence use weights:
sureg (refinfo1 year2009) (refinfo2 year2009) (refinfo3 year2009) (refinfo4 year2009) (       refinfo5 year2009) (refinfo6 year2009) [aweight=weight]
test year2009
*Get N's:
tab refinfo year

*calculations for figure 2:
*Use same info questions for both years:
replace refinfo = refinfocomp09/6 if year==2009
svy, subpop(year2005): tab choiceref refinfo, col
svy, subpop(year2009): tab choiceref refinfo, col
tab choiceref refinfo if year==2005
tab choiceref refinfo if year==2009
*Latter four results are used to create figure 2
svy: reg choiceref refinfo year2009
gen refinfox2009 = refinfo*year2009
svy: reg choiceref refinfo refinfox2009 year2009
svy: probit choiceref refinfo year2009
svy: probit choiceref refinfo refinfox2009 year2009
*Exact calculation of t value for last case gives p = 00055, hence rounds to .001 but is 
* signif at .001

*calculations for figure 3:
svy: tab refinterest year, col pearson
* get N's for previous table:
tab refinterest if year==2005
tab refinterest if year==2009
*Now with DK out:  This is the one used in the paper (prior results show that
* pattern is roughly same either way)
gen refinterestnew = refinterest
replace refinterestnew = . if d2==98 | D2==98
svy: tab refinterestnew year, col pearson
* get N's for previous table:
tab refinterestnew if year==2005
tab refinterestnew if year==2009

* calculations for fig. 7:
*Two versions of signif test for Liberals:
svy: tab choiceref year if choiceprov==1, col pearson
gen cat3 = 0
replace cat3 = 1 if choiceprov==1
svy, subpop(cat3): tab choiceref year, col pearson

svy: tab choiceref year if choiceprov==2, col
svy: tab choiceref year if choiceprov==3, col

* find Ns for previous table
tab choiceprov year if choiceref!=.

*Figures 8 and 9 are in Stephenson file.

*New version of figure 3 with just bars for means:
*Version with DK out:  This is the one used in the paper (prior results show that
* pattern is same either way)

svy: reg refinterestnew year2009
gen refinterestnewint = round(10*refinterestnew)
tab refinterestnewint
svy: probit refinterestnewint year2009
* get N's for previous table (repeats previous calculation:
tab refinterestnew if year==2005
tab refinterestnew if year==2009

* calculations for figure 4 and related discussion:
svy : tab trustcitassmb choiceprov if year==2005, col pearson
svy : tab trustcitassmb choiceprov if year==2009, col pearson
svy : tab trustcitassmb choiceprov if choiceprov<4 & year==2005, col pearson
svy : tab trustcitassmb choiceprov if choiceprov<4 & year==2009, col pearson
*Check that same result if done differently (yes except trivial difference
*in signif levels due to second one using more appropriate subsampling rule):
gen noDKchoiceprov = 0
replace noDKchoiceprov = 1 if choiceprov < 4
gen cat1 = year2005*noDKchoiceprov
gen cat2 = year2009*noDKchoiceprov
drop if cat1==0 & cat2==0
svy, subpop(cat1) : tab trustcitassmb choiceprov, col pearson
svy, subpop(cat2) : tab trustcitassmb choiceprov, col pearson

*Previous calculations use DK and refused = don't trust CA.  
*Now change to dropping them, as used in paper.  Above results show pattern is 
* same either way.

svy, subpop(cat1) : tab trustcitassmb if j1<6
svy, subpop(cat2) : tab trustcitassmb if J1<6
svy, subpop(cat1) : tab trustcitassmb choiceprov if j1<6, col pearson
svy, subpop(cat2) : tab trustcitassmb choiceprov if J1<6, col pearson

*Now the Ns, with Tories and refused dropped:
tab trustcitassmb choiceprov if cat1==1 & j1<6
tab trustcitassmb choiceprov if cat2==1 & J1<6

*calculations for figure 5 are in Ontario file.
*calculations for figure 6 from aggregate data--separate files.


log close